package com.jianganming.singleton;

import java.util.Objects;

/**
 * 静态内部类
 * 特点：效果类似双重检测锁，只适用于静态类
 */
public class Singleton4 {
    private static Singleton4 singleton;
    private Singleton4(){}

    public static Singleton4 getInstance(){
        return SingletonHolder.instance;
    }

    private static class SingletonHolder{
        private static final Singleton4 instance = new Singleton4();
    }

    public static void main(String[] args) {
        Singleton4 instance = Singleton4.getInstance();
        Singleton4 instance1 = Singleton4.getInstance();
        System.out.println(instance==instance1);
    }
}
